Simple Example Using Redis Keys

Description

Redis can be used to get/set keys/value pairs.

Perhaps the simplest use of Redis is storing key/value pairs. This feature allows for variables that can be saved and retrieved across applications.

The Get method retrieves a key value. If a key does not yet exist, a type of 'Nil' will be returned in the RedisResult.

dim redis as extension::RedisClient = extension::RedisClient::CreateClient()
dim key as extension::RedisResult
key = redis.Get("MyMessage")
? key.type
= "Nil"
? key.valueString
= ""

The Set method is used to set either a string or numeric value to a key.

redis.Set("MyMessage","Hello world")
key = redis.Get("MyMessage")
? key.type
= "String"
? key.valueString
= "Hello world"

The Del method is used to remove a key from Redis.

redis.Del("MyMessage")
key = redis.Get("MyMessage")
? key.type
= "Nil"
? key.valueString
= ""